<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    cookie的seal
    <script>
        
        // setCookie('age','18')
        // setCookie('age','18',{
        //     path:'/user'
        // })
        // setCookie('www','18',{
        //     expires: 3
        // })
        function setCookie(key,val,ops={}){


            const p = ops.path ? ';path='+ops.path : ''
            let d = new Date
            if(ops.expires){
                d.setDate(d.getDate() + ops.expires)
                d = ';expires=' + d
            }else{
                d = ''
            }

            document.cookie = `${key}=${val}${p}${d}`
        }

        function getCookie(key){
            const arr = document.cookie.split(' ;')
            for(let i=0;i<arr.length;i++){
                arr[i].split('=')
            }
        }
    </script>
</body>
</html>